package com.company.practice;

/**
 * @description: some desc
 * @author: ruoan
 * @date: 2020/12/30 12:11
 */
public class Test24 {



}
// class SingleForkTask extends RecursiveTask<Map<String,BigDecimal>>
//{
//    //这里继承的是RecursiveTask，适用于有返回值的场景
////还可以继承RecursiveAction，适合于没有返回值的场景
//    private static final long serialVersionUID = 1L;
//    //调用接口  private PlCapaServiceInterface PlCapaService;
//    //设置阀值，超过这个数，则进行拆分  private static final int THRESHOLD = 50;
//    //任务需要用的参数A  private PlEquBO plEquBO;
////任务需要用的参数B  private List<PlEqugrpBO>  list;
//    public SingleForkTask(PlEquBO plEquBO,List<PlEqugrpBO>  list)
//    {
//        this.plEquBO = plEquBO;
//        this.list = list;
//    }
//    @Override
//    protected Map<String,BigDecimal> compute()
//    {
//        Map<String,BigDecimal> result = new HashMap<String,BigDecimal>();
////判断是否超过拆分的阀值    boolean canCompute = list.size() <= THRESHOLD;
//        PlCapaService = findBean();
//        if(canCompute){
//            BigDecimal sigleEquResult = BigDecimal.ZERO;
//            for(PlEqugrpBO cond : list){
//                sigleEquResult = BigDecimal.ZERO;
//                plEquBO.setEquNo(cond.getEquNo());
//                try {
//                    sigleEquResult = PlCapaService.getSingleResult(plEquBO);
////获取值
//                }
//                catch (EnhanceException enEx)
//                {
////EnhanceException extends RuntimeException
//                    throw enEx;
//                }
//                catch(Exception ex){
//                    throw new RuntimeException(ex.getMessage());
//                }
//                result.put(cond.getEquNo(), sigleEquResult);
//            }
//        }
//        else{
////超过需要拆分的阀值,则拆分为两份
//            List<PlEqugrpBO> leftList = list.subList(0, THRESHOLD);
//            List<PlEqugrpBO> rightList = list.subList(THRESHOLD, list.size());
//            SingleForkTask leftTask = new SingleForkTask(plEquBO,leftList);
//            SingleForkTask rightTask = new SingleForkTask(plEquBO,rightList);
//            //fork：执行子任务的调用
//            leftTask.fork();
//            rightTask.fork();
//            //join:获取任务的结果
//            Map<String,BigDecimal> leftResult = leftTask.join();
//            Map<String,BigDecimal> rightResult = rightTask.join();
//            //若无返回值和无异常抛出的情况，则可以考虑invokeAll(leftTask, rightTask);
//            leftResult.putAll(rightResult);
//            result.putAll(leftResult);
//        }
//        return result;
//    }
//    public static PlCapaServiceInterface   findBean()
//    {
//        return EjbBean.findBean(PlCapaServiceInterface.class);
//    }
//}
